package com.shengqin.config;

import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.stp.StpUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@Slf4j
public class RequestConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
                .addPathPatterns("/**")
                .excludePathPatterns("/admin/v1/user/login",
                        "/admin/v1/student/import",
                        "/admin/v1/testResult/importTestData",
                        "/admin/v1/student/photoImport",
                        "/admin/v1/plan/apply/import",
                        "/admin/v1/project/import",
                        "/admin/v1/project/importStandard",
                        "/admin/v1/plan/importFreeTestData",
                        "/admin/v1/student/photoUpload",
                        "/admin/v1/school/import",
                        "/admin/v1/user/getVerify",
                        "/admin/v1/freeTest/refresh",
                        "/actuator/**",
                        "/api/**","/swagger-ui/**","/swagger-resources/**", "/swagger-ui.html/**","/v3/**");
    }

}
